def Run(self, args): parent_ref = args.CONCEPTS.location.Parse() return apis.ApiClient().List(parent_ref.RelativeName(), filters=args.filter, limit=args.limit, page_size=args.page_size, sort_by=args.sort_by)
def Run(self, args): api_ref = args.CONCEPTS.api.Parse() api_client = apis.ApiClient() api, mask = self.ProcessUpdates(api_client.Get(api_ref), args) resp = api_client.Update(api, update_mask=mask) return operations_util.PrintOperationResult( resp.name, operations.OperationsClient(), service=api_client.service, wait_string='Waiting for API [{}] to be updated'.format(api_ref.Name()), is_async=args.async_)
def Run(self, args): apis = apis_client.ApiClient() api_configs = api_configs_client.ApiConfigClient() ops = operations_client.OperationsClient() api_config_ref = args.CONCEPTS.api_config.Parse() api_ref = api_config_ref.Parent() # Check to see if Api exists, create if not if not apis.DoesExist(api_ref): res = apis.Create(api_ref) operations_util.PrintOperationResult( res.name, ops, wait_string='Waiting for API [{}] to be created'.format( api_ref.Name())) open_api_docs = [] svc_configs = [] grpc_svc_defs = [] # When we add gRPC support back, we can remove the 'hasattr' call. if hasattr(args, 'grpc_files') and args.grpc_files: args.grpc_files = [f.strip() for f in args.grpc_files] svc_configs, grpc_svc_defs = self.__GrpcMessages(args.grpc_files) else: args.openapi_spec = [f.strip() for f in args.openapi_spec] open_api_docs = self.__OpenApiMessage(args.openapi_spec) # Create ApiConfig object. # Only piece affected by async right now resp = api_configs.Create( api_config_ref, labels=args.labels, display_name=args.display_name, backend_auth=args.backend_auth_service_account, managed_service_configs=svc_configs, grpc_service_defs=grpc_svc_defs, open_api_docs=open_api_docs) wait = 'Waiting for API Config [{0}] to be created for API [{1}]'.format( api_config_ref.Name(), api_ref.Name()) return operations_util.PrintOperationResult( resp.name, ops, service=api_configs.service, wait_string=wait, is_async=args.async_)
def Run(self, args): api_ref = args.CONCEPTS.api.Parse() api_client = apis.ApiClient() resp = api_client.Create(api_ref, managed_service=args.managed_service, labels=args.labels, display_name=args.display_name) return operations_util.PrintOperationResult( resp.name, ops.OperationsClient(), service=api_client.service, wait_string='Waiting for API [{}] to be created'.format( api_ref.Name()), is_async=args.async_)
def Run(self, args): apis = apis_client.ApiClient() api_configs = api_configs_client.ApiConfigClient() ops = operations_client.OperationsClient() api_config_ref = args.CONCEPTS.api_config.Parse() api_ref = api_config_ref.Parent() service_name = '{}.apigateway.{}.cloud.goog'.format( api_ref.Name(), api_ref.projectsId) # Check if OP service exists with Api name, create if not, activate it if not endpoints.DoesServiceExist(service_name): endpoints.CreateService(service_name, api_ref.projectsId) # Check to see if Api exists, create if not if not apis.DoesExist(api_ref): res = apis.Create(api_ref, service_name) ops.GetOperationResult(res) # Create OP ServiceConfig and Rollout if args.openapi_spec: service_config_id = self.__PushOpenApiServiceFile( args.openapi_spec, service_name, api_config_ref.projectsId, config_id=api_config_ref.Name()) else: service_config_id = self.__PushGrpcConfigFiles( args.grpc_files, service_name, api_config_ref.projectsId, config_id=api_config_ref.Name()) rollout = endpoints.CreateRollout(service_config_id, service_name) # Create ApiConfig object using the service config and rollout # Only piece affected by async right now resp = api_configs.Create( api_config_ref, rollout['rolloutId'], labels=args.labels, display_name=args.display_name, backend_auth=args.backend_auth_service_account) return ops.GetOperationResult(resp, is_async=args.async_)
def Run(self, args): api_ref = args.CONCEPTS.api.Parse() service_name = common_flags.ProcessApiRefToEndpointsService(api_ref) api_client = apis.ApiClient() # Check if OP service exists with Api name, create if not, activate it if not endpoints.DoesServiceExist(service_name): endpoints.CreateService(service_name, api_ref.projectsId) resp = api_client.Create(api_ref, service_name, labels=args.labels, display_name=args.display_name) return operations_util.PrintOperationResult( resp.name, ops.OperationsClient(), service=api_client.service, wait_string='Waiting for API [{}] to be created'.format(api_ref.Name()), is_async=args.async_)
def Run(self, args): api_ref = args.CONCEPTS.api.Parse() return apis.ApiClient().RemoveIamPolicyBinding(api_ref, args.member, args.role)
def Run(self, args): api_ref = args.CONCEPTS.api.Parse() return apis.ApiClient().GetIamPolicy(api_ref)
def Run(self, args): apis = apis_client.ApiClient() api_configs = api_configs_client.ApiConfigClient() ops = operations_client.OperationsClient() api_config_ref = args.CONCEPTS.api_config.Parse() api_ref = api_config_ref.Parent() service_name = '{}.apigateway.{}.cloud.goog'.format( api_ref.Name(), api_ref.projectsId) # Check if OP service exists with Api name, create if not, activate it if not endpoints.DoesServiceExist(service_name): endpoints.CreateService(service_name, api_ref.projectsId) # Check to see if Api exists, create if not if not apis.DoesExist(api_ref): res = apis.Create(api_ref, service_name) operation_ref = resources.REGISTRY.Parse( res.name, collection='apigateway.projects.locations.operations') ops.WaitForOperation( operation_ref, 'Waiting for API [{}] to be created'.format(api_ref.Name())) # Create OP ServiceConfig and Rollout if args.openapi_spec: service_config_id = self.__PushOpenApiServiceFile( args.openapi_spec, service_name, api_config_ref.projectsId, config_id=api_config_ref.Name()) else: service_config_id = self.__PushGrpcConfigFiles( args.grpc_files, service_name, api_config_ref.projectsId, config_id=api_config_ref.Name()) rollout = endpoints.CreateRollout(service_config_id, service_name) # Create ApiConfig object using the service config and rollout # Only piece affected by async right now resp = api_configs.Create( api_config_ref, rollout['rolloutId'], labels=args.labels, display_name=args.display_name, backend_auth=args.backend_auth_service_account) operation_ref = resources.REGISTRY.Parse( resp.name, collection='apigateway.projects.locations.operations') # If async operation, simply log and return the result on passed in object if args.async_: operations_util.PrintOperationResultWithWaitEpilogue( operation_ref, 'Asynchronous operation is in progress') return resp return ops.WaitForOperation( operation_ref, 'Waiting for API Config [{}] to be created for API [{}]'.format( api_config_ref.Name(), api_ref.Name()), api_configs.client.projects_locations_apis_configs)
def Run(self, args): apis = apis_client.ApiClient() api_configs = api_configs_client.ApiConfigClient() ops = operations_client.OperationsClient() api_config_ref = args.CONCEPTS.api_config.Parse() api_ref = api_config_ref.Parent() service_name = common_flags.ProcessApiRefToEndpointsService(api_ref) # Check if OP service exists with Api name, create if not, activate it if not endpoints.DoesServiceExist(service_name): endpoints.CreateService(service_name, api_ref.projectsId) # Check to see if Api exists, create if not if not apis.DoesExist(api_ref): res = apis.Create(api_ref, service_name) operations_util.PrintOperationResult( res.name, ops, wait_string='Waiting for API [{}] to be created'.format( api_ref.Name())) # Create OP ServiceConfig and Rollout # Creating a suffix to avoid name collisions on ServiceConfig IDs. suffix = '-' + str(int(time.time())) length = MAX_SERVICE_CONFIG_ID_LENGTH - len(suffix) config_id = api_config_ref.Name()[:length] + suffix if args.openapi_spec: service_config_id = self.__PushOpenApiServiceFile( args.openapi_spec, service_name, api_config_ref.projectsId, config_id=config_id) else: service_config_id = self.__PushGrpcConfigFiles( args.grpc_files, service_name, api_config_ref.projectsId, config_id=config_id) rollout = endpoints.CreateRollout(service_config_id, service_name) # Create ApiConfig object using the service config and rollout # Only piece affected by async right now resp = api_configs.Create( api_config_ref, rollout['rolloutId'], labels=args.labels, display_name=args.display_name, backend_auth=args.backend_auth_service_account) wait = 'Waiting for API Config [{}] to be created for API [{}]'.format( api_config_ref.Name(), api_ref.Name()) return operations_util.PrintOperationResult( resp.name, ops, service=api_configs.service, wait_string=wait, is_async=args.async_)