github.com/IBM-Cloud/bluemix-go@v0.0.0-20240423071914-9e96525baef4/api/functions/functions_util.go (about) 1 package functions 2 3 import "github.com/go-openapi/strfmt" 4 5 // GetNamespacesOptions : The GetNamespaces options. 6 type GetNamespacesOptions struct { 7 8 // The maximum number of namespaces to return. Default 100. Maximum 200. 9 Limit *int64 `json:"limit,omitempty"` 10 11 // The number of namespaces to skip. Default 0. 12 Offset *int64 `json:"offset,omitempty"` 13 14 // Allows users to set headers to be GDPR compliant 15 Headers map[string]string 16 } 17 18 // NamespaceResponse : NamespaceResponse - create/get response. 19 type NamespaceResponse struct { 20 21 // Time the API key was activated. 22 APIKeyCreated *strfmt.DateTime `json:"API_key_created,omitempty"` 23 24 // ID of API key used by the namespace. 25 APIKeyID *string `json:"API_key_id,omitempty"` 26 27 // CF space GUID of classic namespace - present if it is or was a classic namespace. 28 ClassicSpaceguid *string `json:"classic_spaceguid,omitempty"` 29 30 // ClassicType <br/> This attribute will be absent for an IAM namespace, a namespace which is IAM-enabled and not 31 // associated with any CF space. <br/> 1 : Classic - A namespace which is associated with a CF space. <br/> Such 32 // namespace is NOT IAM-enabled and can only be used by using the legacy API key ('entitlement key'). <br/> 2 : Classic 33 // IAM enabled - A namespace which is associated with a CF space and which is IAM-enabled. <br/> It accepts IMA token 34 // and legacy API key ('entitlement key') for authorization.<br/> 3 : IAM migration complete - A namespace which was/is 35 // associated with a CF space, which is IAM-enabled. <br/> It accepts only an IAM token for authorization.<br/>. 36 ClassicType *int64 `json:"classic_type,omitempty"` 37 38 // CRN of namespace - absent if namespace is NOT IAM-enabled. 39 Crn *string `json:"crn,omitempty"` 40 41 // Description - absent if namespace is NOT IAM-enabled. 42 Description *string `json:"description,omitempty"` 43 44 // UUID of namespace. 45 ID *string `json:"id" validate:"required"` 46 47 // Location of the resource. 48 Location *string `json:"location" validate:"required"` 49 50 // Name - absent if namespace is NOT IAM-enabled. 51 Name *string `json:"name,omitempty"` 52 53 // Resourceplanid used - absent if namespace is NOT IAM-enabled. 54 ResourcePlanID *string `json:"resource_plan_id,omitempty"` 55 56 // Resourcegrpid used - absent if namespace is NOT IAM-enabled. 57 ResourceGroupID *string `json:"resource_group_id,omitempty"` 58 59 // Serviceid used by the namespace - absent if namespace is NOT IAM-enabled. 60 ServiceID *string `json:"service_id,omitempty"` 61 62 // Key used by the cf based namespace. 63 Key string `json:"key,omitempty"` 64 65 // UUID used by the cf based namespace. 66 UUID string `json:"uuid,omitempty"` 67 } 68 69 // NamespaceResponseList : NamespaceResponseList -. 70 type NamespaceResponseList struct { 71 72 // Maximum number of namespaces to return. 73 Limit *int64 `json:"limit" validate:"required"` 74 75 // List of namespaces. 76 Namespaces []NamespaceResponse `json:"namespaces" validate:"required"` 77 78 // Number of namespaces to skip. 79 Offset *int64 `json:"offset" validate:"required"` 80 81 // Total number of namespaces available. 82 TotalCount *int64 `json:"total_count" validate:"required"` 83 } 84 85 // CreateNamespaceOptions : The CreateNamespace options. 86 type CreateNamespaceOptions struct { 87 88 // Name. 89 Name *string `json:"name" validate:"required"` 90 91 // Resourcegroupid of resource group the namespace resource should be placed in. Use 'ibmcloud resource groups' to 92 // query your resources groups and their ids. 93 ResourceGroupID *string `json:"resource_group_id" validate:"required"` 94 95 // Resourceplanid to use, e.g. 'functions-base-plan'. 96 ResourcePlanID *string `json:"resource_plan_id" validate:"required"` 97 98 // Description. 99 Description *string `json:"description,omitempty"` 100 101 // Allows users to set headers to be GDPR compliant 102 Headers map[string]string 103 } 104 105 // GetNamespaceOptions : The GetNamespace options. 106 type GetNamespaceOptions struct { 107 108 // The id of the namespace to retrieve. 109 ID *string `json:"id" validate:"required"` 110 111 // Allows users to set headers to be GDPR compliant 112 Headers map[string]string 113 } 114 115 // DeleteNamespaceOptions : The DeleteNamespace options. 116 type DeleteNamespaceOptions struct { 117 118 // The id of the namespace to delete. 119 ID *string `json:"id" validate:"required"` 120 121 // Allows users to set headers to be GDPR compliant 122 Headers map[string]string 123 } 124 125 // UpdateNamespaceOptions : The UpdateNamespace options. 126 type UpdateNamespaceOptions struct { 127 128 // The id of the namespace to update. 129 ID *string `json:"id" validate:"required"` 130 131 // New description. 132 Description *string `json:"description,omitempty"` 133 134 // New name. 135 Name *string `json:"name,omitempty"` 136 137 // Allows users to set headers to be GDPR compliant 138 Headers map[string]string 139 } 140 141 //NamespaceResource .. 142 type NamespaceResource interface { 143 GetID() string 144 GetLocation() string 145 GetName() string 146 GetUUID() string 147 GetKey() string 148 IsIamEnabled() bool 149 IsCf() bool 150 } 151 152 //GetID .. 153 func (ns *NamespaceResponse) GetID() string { 154 return *ns.ID 155 } 156 157 //GetName .. 158 func (ns *NamespaceResponse) GetName() string { 159 // Classic support - if no name included in namespace obj return the ID (classic namespace name) 160 if ns.Name != nil { 161 return *ns.Name 162 } 163 return *ns.ID 164 } 165 166 //GetKey .. 167 func (ns *NamespaceResponse) GetKey() string { 168 return ns.Key 169 } 170 171 //GetUUID .. 172 func (ns *NamespaceResponse) GetUUID() string { 173 return ns.UUID 174 } 175 176 //GetLocation .. 177 func (ns *NamespaceResponse) GetLocation() string { 178 return *ns.Location 179 } 180 181 //IsCf .. 182 func (ns *NamespaceResponse) IsCf() bool { 183 var iscf bool = false 184 if ns.ClassicType != nil { 185 iscf = (*ns.ClassicType == NamespaceTypeCFBased) 186 } 187 return iscf 188 } 189 190 //IsIamEnabled .. 191 func (ns *NamespaceResponse) IsIamEnabled() bool { 192 // IAM support - classic_type field is not included for new IAM namespaces so always return true if nil 193 if ns.ClassicType == nil { 194 return true 195 } 196 return false 197 } 198 199 //IsMigrated .. 200 func (ns *NamespaceResponse) IsMigrated() bool { 201 if *ns.ClassicType == NamespaceTypeIamMigrated { 202 return true 203 } 204 return false 205 }