|
| 1 | +/* |
| 2 | + * Copyright 2020 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.google.firebase.auth; |
| 18 | + |
| 19 | +import com.google.api.client.util.Key; |
| 20 | +import com.google.auto.value.AutoValue; |
| 21 | + |
| 22 | +/** |
| 23 | + * Contains metadata associated with a Firebase tenant. |
| 24 | + * |
| 25 | + * <p>Instances of this class are immutable and thread safe. |
| 26 | + */ |
| 27 | +public final class Tenant { |
| 28 | + |
| 29 | + @Key("tenantId") |
| 30 | + private String tenantId; |
| 31 | + |
| 32 | + @Key("displayName") |
| 33 | + private String displayName; |
| 34 | + |
| 35 | + @Key("allowPasswordSignup") |
| 36 | + private String passwordSignInAllowed; |
| 37 | + |
| 38 | + @Key("enableEmailLinkSignin") |
| 39 | + private String emailLinkSignInEnabled; |
| 40 | + |
| 41 | + /** |
| 42 | + * Class used to hold the information needs to make a tenant create request. |
| 43 | + */ |
| 44 | + @AutoValue |
| 45 | + public abstract static class CreateRequest { |
| 46 | + |
| 47 | + /** |
| 48 | + * Returns the display name of this tenant. |
| 49 | + * |
| 50 | + * @return a non-empty display name string. |
| 51 | + */ |
| 52 | + public abstract String getDisplayName(); |
| 53 | + |
| 54 | + /** |
| 55 | + * Returns whether to allow email/password user authentication. |
| 56 | + * |
| 57 | + * @return true if a user can be authenticated using an email and password, and false otherwise. |
| 58 | + */ |
| 59 | + public abstract boolean isPasswordSignInAllowed(); |
| 60 | + |
| 61 | + /** |
| 62 | + * Returns whether to enable email link user authentication. |
| 63 | + * |
| 64 | + * @return true if a user can be authenticated using an email link, and false otherwise. |
| 65 | + */ |
| 66 | + public abstract boolean isEmailLinkSignInEnabled(); |
| 67 | + |
| 68 | + /** |
| 69 | + * Returns a builder for a tenant create request. |
| 70 | + */ |
| 71 | + public static Builder newBuilder() { |
| 72 | + return new AutoValue_Tenant_CreateRequest.Builder(); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Builder class used to construct a create request. |
| 77 | + */ |
| 78 | + @AutoValue.Builder |
| 79 | + abstract static class Builder { |
| 80 | + public abstract Builder setDisplayName(String displayName); |
| 81 | + |
| 82 | + public abstract Builder setPasswordSignInAllowed(boolean allowPasswordSignIn); |
| 83 | + |
| 84 | + public abstract Builder setEmailLinkSignInEnabled(boolean enableEmailLinkSignIn); |
| 85 | + |
| 86 | + public abstract CreateRequest build(); |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * Class used to hold the information needs to make a tenant update request. |
| 92 | + */ |
| 93 | + @AutoValue |
| 94 | + public abstract static class UpdateRequest { |
| 95 | + |
| 96 | + /** |
| 97 | + * Returns the display name of this tenant. |
| 98 | + * |
| 99 | + * @return a non-empty display name string. |
| 100 | + */ |
| 101 | + public abstract String getDisplayName(); |
| 102 | + |
| 103 | + /** |
| 104 | + * Returns whether to allow email/password user authentication. |
| 105 | + * |
| 106 | + * @return true if a user can be authenticated using an email and password, and false otherwise. |
| 107 | + */ |
| 108 | + public abstract boolean isPasswordSignInAllowed(); |
| 109 | + |
| 110 | + /** |
| 111 | + * Returns whether to enable email link user authentication. |
| 112 | + * |
| 113 | + * @return true if a user can be authenticated using an email link, and false otherwise. |
| 114 | + */ |
| 115 | + public abstract boolean isEmailLinkSignInEnabled(); |
| 116 | + |
| 117 | + /** |
| 118 | + * Returns a builder for a tenant update request. |
| 119 | + */ |
| 120 | + public static Builder newBuilder() { |
| 121 | + return new AutoValue_Tenant_UpdateRequest.Builder(); |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * Builder class used to construct a update request. |
| 126 | + */ |
| 127 | + @AutoValue.Builder |
| 128 | + abstract static class Builder { |
| 129 | + public abstract Builder setDisplayName(String displayName); |
| 130 | + |
| 131 | + public abstract Builder setPasswordSignInAllowed(boolean allowPasswordSignIn); |
| 132 | + |
| 133 | + public abstract Builder setEmailLinkSignInEnabled(boolean enableEmailLinkSignIn); |
| 134 | + |
| 135 | + public abstract UpdateRequest build(); |
| 136 | + } |
| 137 | + } |
| 138 | +} |
0 commit comments